<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            var lemonadeChange = function (bills) {
                let five,
                    ten,
                    twenty = 0
                for (let i = 0; i < bills.length; i++) {
                    switch (bills[i]) {
                        case 5:
                            five++
                            break
                        case 10:
                            if (five >= 1) {
                                five--
                                ten++
                            } else {
                                return false
                            }
                            break
                        case 20:
                            if (ten >= 1 && five >= 1) {
                                ten--
                                five--
                                twenty++
                            } else if (five >= 3) {
                                five -= 3
                                twenty++
                            } else {
                                return false
                            }
                            break
                    }
                }
                return true
            }
            console.log(lemonadeChange([5, 5, 10, 10, 20]))
        </script>
    </body>
</html>
